import axiox from "axios";

const apiUrl = "http://172.16.10.23:88/";
const fetchToken = () => {
  const token = localStorage.getItem("token");
  return token;
};

const request = (url, data) => {
  const token = fetchToken();
  axios.defaults.headers.post["Token"] = token;
  return new Promise((resolve, reject) => {
    axios
      .post(apiUrl + url, data)
      .then((res) => {
        if (res.status == 200) {
          resolve(res.data);
        }
      })
      .catch((error) => {
        ElMessage({
          type: "error",
          message: error.message,
        });
        reject(error);
      });
  });
};

export default axiox;
